package com.ss.android.gallery.base.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.ss.android.gallery.comic.R;

public abstract class BaseSplashActivity extends Activity{
	private volatile boolean mActive=true;
	private int mSplashTime=1000;
	private Runnable mTask;
	private View mView;
	
	private void goMainActivity(){
		this.mTask=null;
		if(!this.mActive){
			return;
		}
		startActivity(getMainIntent());
		finish();
	}
	
	private void init(){
		this.mTask=new Runnable(){
			public void run(){
				BaseSplashActivity.this.goMainActivity();
			}
		};
		this.mView.postDelayed(this.mTask, this.mSplashTime);
		doInit();
	}
	
	protected void doInit(){
		//AppData.inst().tryInit(this);
	}
	
	protected abstract Intent getMainIntent();
	
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.splash_activity);
		this.mView=findViewById(R.id.splash_view);
		this.mActive=true;
		init();
		Intent intent=getIntent();
		if(intent!=null){
			Bundle bundle=intent.getExtras();
			if(bundle!=null&&bundle.getBoolean("from_notification")){
				//AsyncMobClickTask.onEvent(this,"more_tab","notify_click");
			}
		}
	}
	
	@Override
	public void onDestroy(){
		if(this.mTask!=null){
			this.mView.removeCallbacks(this.mTask);
		}
		this.mActive=false;
		super.onDestroy();
	}
	
	@Override
	protected void onPause(){
		super.onPause();
		//MobClickCombiner.onPause(this);
	}
	
	@Override
	protected void onResume(){
		super.onResume();
		//MobClickCombiner.onResume(this);
	}
}
